import request from '@/util/request'

export function updateDevice(data) {
  return request({
    url: '/device/device',
    method: 'put',
    data: data,
	isToken:true
  })
}

export function getDeviceList(req: any){
    return request({
        url: '/device/device/list',
        method: 'get',
        params: req,
		isToken:true
    })
}

export function getDevice(req: any){
    return request({
        url: `/device/device/${req.id}`,
        method: 'get',
		isToken:true
    })
}


// 传感器控制
export function getDeviceCommand(data) {
  return request({
    url: '/device/device/command',
    method: 'post',
    data:data,
	isToken: true
  })
}

// 当前固件
export function getfirmwareUpgrade(req: any) {
  return request({
    url: '/firmware/firmwareUpgrade/current',
    method: 'get',
	params:{},
	isToken:true
  })
}

// 升级固件
export function upgrade(data) {
  return request({
    url: '/device/device/upgrade',
    method: 'post',
    data:data
  })
}

export function getTrendData(req: any) {
	return request({
	  url: '/data/sensorData/trendData',
	  method: 'get',
	  params:req,
	  isToken:true
	})  
}

//删除设备控制组合
export function delMergeControl(req) {
  return request({
    url: `/device/mergeControl/${req.id}`,
    method: 'delete',
	isToken:true
  })
}

//设备控制组合命令
export function multipleCommand(data) {
  return request({
    url: `/device/device/multipleCommand`,
    method: 'post',
    data:data,
	isToken:true
  })
}


//新增设备控制组合
export function createMergeControl(data) {
  return request({
    url: '/device/mergeControl/add',
    method: 'post',
    data: data,
	isToken:true
  })
}

//编辑设备控制组合
export function updateMergeControl(data) {
  return request({
    url: '/device/mergeControl/update',
    method: 'put',
    data: data,
	isToken:true
  })
}

// 配置串口标识
export function getDeviceData(id) {
  return request({
    url: '/device/device/getDeviceData/'+id,
    method: 'get',
	isToken:true
  })
}

// 同步时间
export function syncDeviceTime(id) {
  return request({
    url: '/device/device/syncDeviceTime/'+id,
    method: 'get',
	isToken:true
  })
}

// 设备状态
export function getDeviceStatusList(req: any) {
  return request({
    url: '/device/deviceStatus/list/',
    method: 'get',
	params: req,
	isToken:true
  })
}

// 查询设备类型详细
export function deviceTypeOptions() {
  return request({
    url: '/device/deviceType/deviceTypeOptions/',
    method: 'get'
  })
}
